/**
/* Copyright (C) 2011, Catdroid, Bernat Borras
/* 
/* This program is free software; you can redistribute it and/or
/* modify it under the terms of the GNU General Public License
/* as published by the Free Software Foundation in its version 2
/* of the License.
/* 
/* This program is distributed in the hope that it will be useful,
/* but WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/* GNU General Public License for more details.
/*
/* You should have received a copy of the GNU General Public License
/* along with this program; if not, write to the Free Software
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
/* 
/* @author Bernat Borras (@bbpp)
 */

package com.curs.catdroid_demo_life_2;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.android.dataframework.Entity;
import com.androidquery.AQuery;

public class ImageFragment extends Fragment {

	public static final String ARG_ID = "ID_DATO";

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		LinearLayout layout = (LinearLayout) inflater.inflate(
				R.layout.fragment, null);

		ImageView image = (ImageView) layout.findViewById(R.id.image);
		ProgressBar progress = (ProgressBar) layout.findViewById(R.id.progress);

		/**
		 * Recogemos los datos que nos han pasado con el metodo .putArgs()
		 */

		Bundle args = getArguments();

		long id = args.getLong(ARG_ID);

		/**
		 * Cargamos el elemento de la base de datos
		 */
		Entity ent = new Entity("Datos", id);

		AQuery aq = new AQuery(getActivity());

		/**
		 * Descargamos la iamgen de internet
		 */

		aq.id(image).progress(progress)
				.image(ent.getString("URL"), true, true);
		// aq.id(image).image(ent.getString("URL"), true, true);

		return layout;
	}
}
